# -*- coding: utf-8 -*-
# @File     : permissions.py
# @Author   : bingjia
# @Time     : 2020/8/11 10:32
# @Desc     :

from operation.base.api import permissions
from operation.base.api.permissions import IsSuperUser
from operation.base.api.permissions import BasePermission
from operation.base.api.permissions import IsAuthenticated

from operation.permissions.permissions import HasProjectPerm
from operation.permissions.permissions import IsProjectAdmin
from operation.permissions.permissions import IsProjectMembership


class EquipmentPermission(BasePermission):
    """
    数据权限
    """
    # 全局权限
    global_perms = None
    enough_perms = IsSuperUser()

    # 增删改查
    list_perms = IsAuthenticated() & HasProjectPerm("view_equipment")
    create_perms = IsAuthenticated() & HasProjectPerm("create_equipment")
    delete_equipment_perms = IsAuthenticated() & IsProjectAdmin()
    retrieve_perms = IsAuthenticated() & HasProjectPerm("view_equipment")
    update_perms = IsAuthenticated() & HasProjectPerm("view_equipment")


class EquipmentAdminPermission(BasePermission):
    """
    数据管理权限
    """
    enough_perms = IsSuperUser()

    list_perms = IsSuperUser()
    create_perms = IsSuperUser()
    retrieve_perms = IsSuperUser()
    update_perms = IsSuperUser()
    delete_equipment_perms = IsSuperUser()


